home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / dev / lang / pcq12b.lzh / Include / Utils / DateTools.i < prev    next >
Text File  |  1990-08-27  |  2KB  |  83 lines

  1. {
  2.     DateTools.i of PCQ Pascal
  3.  
  4.     These routines help to use AmigaDOS's DateStamps and Intuition's
  5.     CurrentTime(), which, to save memory, are formatted relatively
  6.     inconveniently.  These routines use DateDescription records,
  7.     which have the Year, Month, etc. formatted in normal human
  8.     form.  This module also exports some typed constants that spell
  9.     out the month and day names in case you've forgotten.
  10.  
  11.     The MonthNames and DayNames arrays can be altered or removed
  12.     as necessary.  If you don't use English, for example, you can
  13.     change them in this file and will not need to bother with
  14.     anywhere else.  If you want to save the memory, you can get rid
  15.     of them entirely.  You can't, however, get rid of the DaysInMonth
  16.     array, since that is used by the DateTools routines.
  17. }
  18.  
  19. {$I "Include:Libraries/DOS.i"}
  20.  
  21. Type
  22.     DaysOfTheWeek = (Sunday, Monday, Tuesday, Wednesday,
  23.             Thursday, Friday, Saturday);
  24.  
  25.     DateDescription = record
  26.     Day    : Byte;            { Day of month, 1..31 }
  27.     Month    : Byte;            { Month, 1..12 }
  28.     Year    : Short;        { Year, 1978... }
  29.     DOW    : DaysOfTheWeek;    { Sunday .. Saturday }
  30.     Hour    : Byte;            { 0..23.  0 = 12 AM, 12 = Noon }
  31.     Minute    : Byte;            { 0..59 }
  32.     Second    : Byte;            { 0..59 }
  33.     end;
  34.  
  35. Const
  36.     MonthNames : Array [1..12] of String =
  37.                ("January",
  38.             "February",
  39.             "March",
  40.             "April",
  41.             "May",
  42.             "June",
  43.             "July",
  44.             "August",
  45.             "September",
  46.             "October",
  47.             "November",
  48.             "December");
  49.  
  50.     DayNames : Array [Sunday..Saturday] of String =
  51.                ("Sunday",
  52.             "Monday",
  53.             "Tuesday",
  54.             "Wednesday",
  55.             "Thursday",
  56.             "Friday",
  57.             "Saturday");
  58.  
  59.     { This array changes if you get a date description for
  60.       a leap year date.  Thus if you are going to use these
  61.       values, make sure you set DaysInMonth[1] to the value
  62.       you need.  Also note that this array is zero based,
  63.       unlike the month names above }
  64.  
  65.     DaysInMonth : Array [0..11] of Byte = (31,28,31,30,31,30,
  66.                        31,31,30,31,30,31);
  67.  
  68.  
  69. { Given Total seconds, figure out the day, month, year, time of day,
  70.   etc. }
  71. Procedure GetDescription(Total : Integer; var DD : DateDescription);
  72.     External;
  73.  
  74.  
  75. {  Get a description for the current time }
  76. Procedure TimeDesc(var DD : DateDescription);
  77.     External;
  78.  
  79.  
  80. { Get a description based on a DateStampRec }
  81. Procedure StampDesc(DS : DateStampRec; var DD : DateDescription);
  82.     External;
  83.